/*
 * Copyright (c) 2019 - 2020 IoT Company of Midea Group.
 *
 * File Name 	    : 
 * Description	    : rtos adaptor
 *
 * Version	        : v0.1
 * Author			: 
 * Date	            : 2019/09/15  refactoring
 * History	        : 
 */
#ifndef __MS_OSAL_MUTEX_H__
#define __MS_OSAL_MUTEX_H__

#include <stdint.h>
#include "ms_osal.h"

#ifdef __cplusplus
extern "C"
{
#endif

/**
 * @brief	Create a new mutex
 * @param[in]	mhandle : A handle to the newly created mutex
 * @param[in]	name : 	A descriptive name for the mutex
 * @return if successly, return MS_OSAL_RESULT_SUCCESS, \n
 *         otherwise return MS_OSAL_RESULT_ERROR
 **/
ms_osal_result_t ms_osal_mutex_create(ms_osal_mutex_t *mhandle, const char *name);

/**
 * @brief	Get the mutex that was previously created
 * @param[in]	mhandle : A handle to the mutex being taken
 * @param[in]	msecs : The time in ticks to wait for the mutex to become available
 * @return if successly, return MS_OSAL_RESULT_SUCCESS, \n
 *         otherwise return MS_OSAL_RESULT_ERROR
 **/
ms_osal_result_t ms_osal_mutex_get(ms_osal_mutex_t *mhandle, uint64_t msecs);

/**
 * @brief	Put the mutex that was previously created
 * @param[in]	mhandle : A handle to the mutex being released
 * @return if successly, return MS_OSAL_RESULT_SUCCESS, \n
 *         otherwise return MS_OSAL_RESULT_ERROR
 **/
ms_osal_result_t ms_osal_mutex_put(ms_osal_mutex_t *mhandle);

/**
 * @brief	Delete the mutex that was previously created
 * @param[in]	mhandle : A handle to the mutex that will be deleted
 * @return if successly, return MS_OSAL_RESULT_SUCCESS, \n
 *         otherwise return MS_OSAL_RESULT_ERROR
 **/
ms_osal_result_t ms_osal_mutex_delete(ms_osal_mutex_t *mhandle);

#ifdef __cplusplus
}
#endif

#endif // __MS_OSAL_MUTEX_H__
